package com.ruoyi.project.system.trcode.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.trcode.domain.PaeaParaAuditTrcode;
import com.ruoyi.project.system.trcode.service.IPaeaParaAuditTrcodeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 监控交易码Controller
 *
 * @author ruoyi
 * @date 2020-03-12
 */
@Controller
@RequestMapping("/system/trcode")
public class PaeaParaAuditTrcodeController extends BaseController
{
    private String prefix = "system/trcode";

    @Autowired
    private IPaeaParaAuditTrcodeService paeaParaAuditTrcodeService;

    @RequiresPermissions("system:trcode:view")
    @GetMapping()
    public String trcode()
    {
        return prefix + "/trcode";
    }

    /**
     * 查询监控交易码列表
     */
    @RequiresPermissions("system:trcode:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaParaAuditTrcode paeaParaAuditTrcode)
    {
        startPage();
        List<PaeaParaAuditTrcode> list = paeaParaAuditTrcodeService.selectPaeaParaAuditTrcodeList(paeaParaAuditTrcode);
        return getDataTable(list);
    }

    /**
     * 导出监控交易码列表
     */
    @RequiresPermissions("system:trcode:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaParaAuditTrcode paeaParaAuditTrcode)
    {
        List<PaeaParaAuditTrcode> list = paeaParaAuditTrcodeService.selectPaeaParaAuditTrcodeList(paeaParaAuditTrcode);
        ExcelUtil<PaeaParaAuditTrcode> util = new ExcelUtil<PaeaParaAuditTrcode>(PaeaParaAuditTrcode.class);
        return util.exportExcel(list, "trcode");
    }

    /**
     * 新增监控交易码
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存监控交易码
     */
    @RequiresPermissions("system:trcode:add")
    @Log(title = "监控交易码", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaParaAuditTrcode paeaParaAuditTrcode)
    {
        return toAjax(paeaParaAuditTrcodeService.insertPaeaParaAuditTrcode(paeaParaAuditTrcode));
    }

    /**
     * 修改监控交易码
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        PaeaParaAuditTrcode paeaParaAuditTrcode = paeaParaAuditTrcodeService.selectPaeaParaAuditTrcodeById(id);
        mmap.put("paeaParaAuditTrcode", paeaParaAuditTrcode);
        return prefix + "/edit";
    }

    /**
     * 修改保存监控交易码
     */
    @RequiresPermissions("system:trcode:edit")
    @Log(title = "监控交易码", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaParaAuditTrcode paeaParaAuditTrcode)
    {
        return toAjax(paeaParaAuditTrcodeService.updatePaeaParaAuditTrcode(paeaParaAuditTrcode));
    }

    /**
     * 删除监控交易码
     */
    @RequiresPermissions("system:trcode:remove")
    @Log(title = "监控交易码", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaParaAuditTrcodeService.deletePaeaParaAuditTrcodeByIds(ids));
    }
}
